package com.jse.entity;

import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;

/**
 * 默认缓存实现
 * 
 * @author Administrator
 *
 */
public interface Cache {

	public Log log = Logs.get();
	public NutMap map = new NutMap();

	final String msg = "default cache!";

	public default void init() {
		log.info(msg + " init success!");
	}

	public default Object get(String key) {
		log.info(msg + " get " + key);
		return map.get(key);
	}

	public default boolean isKey(String key) {
		log.info(msg + " isKey " + key);
		return map.containsKey(key);
	}

	public default Object put(String key, Object value) {
		log.info(msg + " put " + key);
		return map.put(key, value);
	}

	public default void set(String key, Object value) {
		log.info(msg + " set " + key);
		map.put(key, value);
	}

	public default void remove(String key) {
		log.info(msg + " remove " + key);
		map.remove(key);
	}

	public default void clear() {
		log.info(msg);
		map.clear();
	}

	public default void setMap(NutMap map) {
		map.putAll(map);
	}

	public default boolean isEmpty() {
		return map.isEmpty();
	}

	public default boolean containsKey(Object key) {
		return map.containsKey(key);
	}

}
